from enum import IntEnum, unique


@unique
class RechargeSourceType(IntEnum):
    """
    充值订单创建来源
    """
    AGENCY_MAN = 1  # 代理后台手动添加
    IM_AUTO = 2  # IM自动创建
    OPERATION_CONSOLE = 3  # 运营控制台


@unique
class OrderStatus(IntEnum):
    """
    订单状态
    状态机：
    CREATED -> (COMMITTED, CANCELED, TIMEOUT,PENDING_REVIEW)
    COMMITTED -> (SUCCESS, FAIL)
    SUCCESS -> (CHASED, CHASE_FROZEN)
    PENDING_REVIEW ->(REVIEW_FAIL,COMMITTED,TIMEOUT)
    """
    CREATED = 1  # 创建新订单
    COMMITTED = 2  # 提交第三方上分
    SUCCESS = 3  # 第三方上分成功
    FAIL = 4  # 第三方上分失败
    CANCELED = 5  # 取消订单
    TIMEOUT = 6  # 超时过期
    CHASED = 7  # 已追款
    PENDING_REVIEW = 8  # 等待审核
    REVIEW_FAIL = 9  # 审核失败
    CHASE_FROZEN = 10  # 成功且不能追分


OrderStatusCN = {
    OrderStatus.CREATED.value: "新建",
    OrderStatus.COMMITTED.value: "提交",
    OrderStatus.SUCCESS.value: "成功",
    OrderStatus.FAIL.value: "失败",
    OrderStatus.CANCELED.value: "取消",
    OrderStatus.TIMEOUT.value: "超时",
    OrderStatus.CHASED.value: "追分",
    OrderStatus.PENDING_REVIEW.value: "待审核",
    OrderStatus.REVIEW_FAIL.value: "审核失败",
    OrderStatus.CHASE_FROZEN.value: "成功且不能追分",
}


@unique
class OrderCommentStar(IntEnum):
    ONE = 1,  # 一星
    TWO = 2,  # 二星
    THREE = 3,  # 三星
    FOUR = 4,  # 四星
    FIVE = 5,  # 五星


@unique
class OrderCommentRank(IntEnum):
    BAD = 1,
    NORMAL = 2,
    GOOD = 3


@unique
class MatchMethod(IntEnum):
    HAND = 1  # 手动匹配
    PAY_INFO = 2  # 通过支付信息匹配
    SPECIAL_AMOUNT = 3  # 通过特殊金额匹配


ORDER_CAN_COMMENT = True

TONGLUE_CONF = {
    "SPECIAL_AMOUNT_CONF": {
        'key': '246426f7be950ce07072fa0beadbb6da0f505512ac71f70f5009cbf8',
        'create_order_url': 'http://103.230.240.228:9001/authority/system/api/place_alipay2bank_order/',
        'revoke_order_url': 'http://103.230.240.228:9001/authority/system/api/revoke_order/',
    },
    "PAY_INFO_CONF": {
        'key': '809562812a604b1884a3dc2167b588712a98fee7b895aa0d15453c40',
        'create_order_url': 'http://103.230.240.228:9001/authority/system/api/place_order/',

    },
    'white_ips': {'52.68.69.135'}

}

SMS_SERVICE_WHITE_IPS = {'103.230.242.129'}

# 定时任务
TASK_TRANS_ORDER = 'order:recharge:trans'
TASK_SMS_MATCH_ORDER = 'order:recharge:sms_match'
TASK_ORDER_TIME_OUT = 'order:status:time_out'
TASK_ORDER_AUTO_COMMENT = 'order:comment:auto'
TASK_ORDER_CHASE_TIME_OUT = 'order:status:chase:time_out'
TASK_EXPORT_DATA = 'sys:export'

# 固定金额匹配是，下调实际支付金额的最大比例
MIN_AMOUNT_RATE = 0.01
